<?php
class ClassInfoAction extends Action
{
    /**
    +----------------------------------------------------------
    *类别添加
    +----------------------------------------------------------
    */

    public function classadd()
    {
        $classadd=new Model("class");
        $classadd->Create();
        $classadd_result=$classadd->add();
        if($classadd_result)
        {
            $this->assign("jumpUrl","classadd");
            $this->success("类别添加成功!");

        }
        else
        {
        $this->display();
        }
    }
     /**
    +----------------------------------------------------------
    *类别列表
    +----------------------------------------------------------
    */
     public function classlist()
    {

         $classlist=M("class");
         $classlist_result=$classlist->select();
         $this->assign("classlistshow",$classlist_result);
         $this->display("classlist");
     }
      /**
    +----------------------------------------------------------
    *修改类别
    +----------------------------------------------------------
    */
      public function classedit()
    {
        $classedit=M("class");
        if(isset($_GET['e_id']))
        {
            $e_id=$_GET['e_id'];
            $edit_result=$classedit->where("c_id=$e_id")->field('c_name')->find();
            $this->assign('e_id',$e_id);
            $this->assign('edit_result',$edit_result);
            $this->display(classedit);
        }
        //更新类别信息
        if(isset($_POST['u_e_id']))
        {
            $u_e_id=$_POST['u_e_id'];
            $classedit->create();
            $info=$classedit->where("c_id=$u_e_id")->save();
            if($info)
            {
                $this->assign("jumpUrl","classlist");
                $this->success("类别修改成功!");
            }

        }
     }
      /**
    +----------------------------------------------------------
    *删除类别
    +----------------------------------------------------------
    */
      public function classdel()
    {
        $classdel=M("class");
        if(isset($_GET['d_id']))
        {
            $d_id=$_GET['d_id'];
            $del_result=$classdel->where("c_id=$d_id")->delete();
            if($del_result)
            {
                $this->assign("jumpUrl","__URL__/classlist");
                $this->success("类别删除成功!");
            }
        }

     }
}
?>
